function init() {
	var cur_idx = null;
	//覆写日历click方法
	JCalendar.click = function(obj){
		//var tmp = document.getElementById("c_today");
		//tmp.parentNode.innerHTML = "<div onmouseover=\"this.style.backgroundColor='#CCC'\" onmouseout=\"this.style.backgroundColor=''\" onclick='JCalendar.click(this)'>" + tmp.innerHTML + "</div>";
		JCalendar.cur_date = parseInt(obj.innerHTML);

		//obj.parentNode.innerHTML = "<span id='c_today' style='background-color:#036;color:#FFF;'>" + obj.innerHTML + "</span>";
		if (JCalendar.onclick) {
			var dt = new Date(JCalendar.cur_year, JCalendar.cur_month - 1, JCalendar.cur_date);
			JCalendar.onclick(JCalendar.cur_year,JCalendar.cur_month,JCalendar.cur_date);
		}
	}
	JCalendar.onclick = function(year, month, date) {
		var daystr = year + "-" + month + "-" + date;
		if(layer){
			layer.hide();
		}
//		$("#day").val(daystr);
//		$("#status").val('1');
//		$("#searchfrm").submit();
        if(cur_idx == 'start') {
            daystr += ' 00:00:00';
            var checktime = $("#end").val();
            if(CompareDate(daystr,checktime)) {
                alert('开始时间不允许大于结束时间');return false;
            }
        } else {
            daystr += ' 23:59:59';
            var checktime = $("#start").val();
            if(CompareDate(checktime,daystr)) {
                alert('开始时间不允许大于结束时间');return false;
            }
        }
        $("#"+cur_idx).val(daystr);
	}
	var layer = $("<div></div>").css({
		"display": "none",
		"position": "absolute",
		"z-index": "2010"
	}).html(new JCalendar().show()).appendTo(document.body);
	$(".click_calendar").click(function() {
        $("#noalltime").attr('checked',true);
		layer.show();
		var pos = $(this).offset();
		layer.css({
			"left": pos.left,
			"top": pos.top
		});
        cur_idx = $(this).attr('type');
//		cur_idx = $(this).attr("id").split("_").pop();
		return false;
	});
}
function CompareDate(d1,d2)
{
  return ((new Date(d1.replace(/-/g,"\/"))) > (new Date(d2.replace(/-/g,"\/"))));
}
$(document).ready(function(){init();});
